package com.example.demo.framework.base;

import java.io.Serializable;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.NoRepositoryBean;

import com.example.demo.framework.CustomPage;

@NoRepositoryBean
public interface BaseRepository<T,ID extends Serializable> extends  JpaRepository<T, ID>,JpaSpecificationExecutor<T> {

	public default CustomPage findCustomPage(Specification<T> specification, Pageable pageable) {
		return new CustomPage(this.findAll(specification, pageable));
	}
	
	public default CustomPage findCustomPage(Pageable pageable) {
		return new CustomPage(this.findAll(pageable));
	}
	
	public default CustomPage customPageTransverter(Page<?> page){
		return new CustomPage(page);
	}

}
